package com.xtkj.superclub_share.controller;

import com.xtkj.commons.JsonResult;
import com.xtkj.superclub_share.service.IShareService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.ArrayList;
import java.util.List;

/**
 * @author lizheqi
 * @create 2019-12-31-14:52
 */
@RestController
@RequestMapping("/share")
public class ShareController {

    @Autowired
    private IShareService shareService;
    /**
     * 获取所有的分享列表
     * @return
     */
    public JsonResult listShares() {
        //通过从数据库取得所有的分享界面数据
        try {
            List<String> shareList = new ArrayList<>();
            return JsonResult.success().setMsg("获取分享列表成功").setData(shareList).setCode(200);
        } catch (Exception e) {
            e.printStackTrace();
            return JsonResult.error().setMsg("获取分享列表数据失败").setCode(400);
        }
    }

    /**
     * 复制链接
     * @return
     */
    public JsonResult getLinkUrl(HttpServletRequest request) {
        //获取链接地址
        try {
            StringBuffer requestURL = request.getRequestURL();
            return JsonResult.success().setMsg("获取链接成功").setData(requestURL).setCode(200);
        } catch (Exception e) {
            e.printStackTrace();
            return JsonResult.error().setMsg("获取链接失败").setCode(400);
        }
    }




}
